'Just place in the code view and start form. Username will appear.

Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Sub Form_Activate()
 Dim Result As Long
 Dim Username As String
 Dim LenUserName As Long
 Cls
 LenUserName = 256
 Username = Space(LenUserName)
 Result = GetUserName(Username, LenUserName)
 If Result <> 0 Then
Print Left$(Username, LenUserName)
 Else
  Print "Error"
 End If
End Sub



